/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Interface;

import java.awt.Font;
import javax.swing.ImageIcon;

/**
 *
 * @author Guilherme
 */
public class Final extends javax.swing.JFrame {

    /**
     * Creates new form Resposta
     */
    public Final () {
        initComponents();
        int totalAcertos = Base.Perguntas.totalAcertos();
        int respondidas = Base.Perguntas.totalRepsondidas();
        lblAcerto.setText(Integer.toString(totalAcertos) + " Acertos");
        lblErro1.setText(Integer.toString(respondidas - totalAcertos )+" Erros");
        double porc = totalAcertos * 100 / respondidas;
        String porcent = Double.toString(porc);
        lblTotal.setText(porcent+" % de acerto.");
        long hora = Base.Perguntas.dif;
        int hr = (int)(hora / 60);
        long min = hora - (hr * 60);
        String m = Long.toString(min);
        String h = Integer.toString(hr);
        Base.Perguntas.init=0;
        Base.Perguntas.fin=0;
        Base.Perguntas.dif=0;
        if(m.length()==1){
            m = "0"+ m;
        }
        if(h.length()==1){
            h = "0"+h;
        }
        lblPosicao.setText("Tempo Total: "+h+":"+m);
        
        if (porc < 60){
            try{
                //trocarImagem e label de aviso
                
                lblMsg.setText("TENTE NOVAMENTE !!!");
                lblMsg.setSize(420, 70);
                lblMsg.setLocation(500, 110);
                lblMsg.setFont(new java.awt.Font("Tahoma", Font.ITALIC + Font.BOLD, 36));
                lblMsg.setForeground(new java.awt.Color(255,0,0));
                lblMsg.repaint();
                lblImagem.setIcon(new ImageIcon(".\\src\\Imagens\\triste.gif"));
                lblImagem.repaint();
            }catch(Exception e){
                
            }
        }
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlResposta = new javax.swing.JPanel();
        btnErrado = new javax.swing.JButton();
        btnCorreto = new javax.swing.JButton();
        btnNovamente = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();
        lblTotal = new javax.swing.JLabel();
        lblAcerto = new javax.swing.JLabel();
        lblErro1 = new javax.swing.JLabel();
        lblPosicao = new javax.swing.JLabel();
        lblImagem = new javax.swing.JLabel();
        lblMsg = new javax.swing.JLabel();
        lblHome = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Quiz Responda e Aprenda");

        pnlResposta.setBackground(new java.awt.Color(253, 199, 111));
        pnlResposta.setPreferredSize(new java.awt.Dimension(920, 583));
        pnlResposta.setLayout(null);

        btnErrado.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        btnErrado.setForeground(new java.awt.Color(255, 0, 0));
        btnErrado.setText("Questões Erradas");
        btnErrado.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pnlResposta.add(btnErrado);
        btnErrado.setBounds(50, 220, 400, 70);

        btnCorreto.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        btnCorreto.setForeground(new java.awt.Color(51, 204, 0));
        btnCorreto.setText("Questões Corretas");
        btnCorreto.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pnlResposta.add(btnCorreto);
        btnCorreto.setBounds(50, 30, 400, 70);

        btnNovamente.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnNovamente.setText("Jogar Novamente");
        btnNovamente.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnNovamente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovamenteActionPerformed(evt);
            }
        });
        pnlResposta.add(btnNovamente);
        btnNovamente.setBounds(400, 510, 160, 40);

        btnCancelar.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        btnCancelar.setText("Sair");
        btnCancelar.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        pnlResposta.add(btnCancelar);
        btnCancelar.setBounds(730, 510, 160, 40);

        lblTotal.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblTotal.setText("% do Jogador");
        pnlResposta.add(lblTotal);
        lblTotal.setBounds(40, 490, 200, 50);

        lblAcerto.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblAcerto.setText("X Acertos");
        pnlResposta.add(lblAcerto);
        lblAcerto.setBounds(60, 140, 130, 50);

        lblErro1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblErro1.setText("X Erros");
        pnlResposta.add(lblErro1);
        lblErro1.setBounds(50, 330, 130, 50);

        lblPosicao.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblPosicao.setText("Tempo Total: ");
        pnlResposta.add(lblPosicao);
        lblPosicao.setBounds(740, 10, 170, 17);

        lblImagem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/fim.gif"))); // NOI18N
        pnlResposta.add(lblImagem);
        lblImagem.setBounds(570, 160, 290, 290);

        lblMsg.setFont(new java.awt.Font("Tahoma", 3, 36)); // NOI18N
        lblMsg.setForeground(new java.awt.Color(51, 204, 0));
        lblMsg.setText("PARABÉNS !!!");
        pnlResposta.add(lblMsg);
        lblMsg.setBounds(580, 110, 340, 70);

        lblHome.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/home.png"))); // NOI18N
        lblHome.setToolTipText("Início");
        lblHome.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblHome.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblHomeMouseClicked(evt);
            }
        });
        pnlResposta.add(lblHome);
        lblHome.setBounds(600, 500, 90, 60);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(pnlResposta, javax.swing.GroupLayout.PREFERRED_SIZE, 941, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(pnlResposta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-946)/2, (screenSize.height-616)/2, 946, 616);
    }// </editor-fold>//GEN-END:initComponents

    private void btnNovamenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovamenteActionPerformed
        Questoes q = new Questoes();
        q.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnNovamenteActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        System.exit(0);
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void lblHomeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblHomeMouseClicked
        Inicial ini = new Inicial();
        ini.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_lblHomeMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Resposta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Resposta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Resposta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Resposta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Final().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnCorreto;
    private javax.swing.JButton btnErrado;
    private javax.swing.JButton btnNovamente;
    private javax.swing.JLabel lblAcerto;
    private javax.swing.JLabel lblErro1;
    private javax.swing.JLabel lblHome;
    private javax.swing.JLabel lblImagem;
    private javax.swing.JLabel lblMsg;
    private javax.swing.JLabel lblPosicao;
    private javax.swing.JLabel lblTotal;
    private javax.swing.JPanel pnlResposta;
    // End of variables declaration//GEN-END:variables
}
